사이트 내 전체검색
PHP
웹사이트 압축률 체크
로빈아빠
https://cmd.kr/php/942 URL이 복사되었습니다.

본문

Compress Your Content
Compressing your content saves bandwidth and improves render time, particular on devices with slow internet connections. But it also reduces load on your server. While it does take some amount of computer power to compress files on the fly, you save much more power by having your server doing fewer things at once. It takes a lot less time to transfer files that are smaller. Your server is therefor, at any given time, maintaining far fewer open connections. There really is no down-side to enabling some form of HTTP compression.

The best way to enable this compression, is by using mod_deflate or mod_gzip. You can use them to automatically compress all HTML, CSS, JavaScript and XML content. And even SVG images, which are a form of xml. If your server is not configured to compress content, and you are unable to change that, there is an alternative. It only applies to HTML, but you can add one simple line of PHP to the top of your documents, to let PHP gzip the HTML on the fly.

Simply add this line to the top of your PHP documents:
<? ob_start("ob_gzhandler"); ?>
It has to be inserted before any content is outputted. It's not as efficient as mod_deflate, but it still works well and saves a ton of bandwidth and processor power.

댓글목록

등록된 댓글이 없습니다.

PHP
871 (1/18P)

Search

Copyright © Cmd 명령어 18.227.114.218